#/usr/bin/python3
# --*-- coding:UTF-8 --*--
# filename : basic.py
# author   : besman
# date     : 2017-12.28

import time
import os

#print("你好!")

'''
python 空行
函数之间或类的方法之间用空行分隔，表示一段新的代码的开始。
类和函数入口之间也用一行空行分隔，以突出函数入口的开始。
'''

# new = input('欢迎光临，请问您怎么称呼？\n')
# print("您好，"+new)

# 日期时间

# import time
#
# print(time.time()) # 时间戳
#
# #print(time.localtime(time.time())) #时间元组
#
# print( time.localtime() )
#
# print(time.asctime( time.localtime(time.time()) )) # asctime 可读的时间模式的函数
#
# print(time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime() ) )
#
# print( time.strftime("%a %b %d %H:%M:%S %Y", time.localtime() ) )

# def printinfo( name ):
#    "打印任何传入的字符串"
#    print ("Name: ", name);
# #   print ("Age ", age);
#    return;
#
# #printinfo(name="yy",age="uu")
# printinfo("uu")


# with open('joke.py','r+') as f:
#     print(f.readline())
#     print(f.tell())
#     print(f.readlines())


# file对象函数

# file.close()
# file.flush()
# file.next()
# file.read([size])
# file.readline([size])
# file.readlines()
# file.seek()
# file.tell()
# file.truncate()
# file.write(str)
# file.writelines(sequence)


# OS 模块

# os.rename("xx", "yy")
# os.remove("xx")
# os.mkdir('newdir')
# os.chdir('otherdir')
# os.getcwd()
# os.rmdir('dirname')  # 删除空目录

# try ... finally ... try语句无论是否发生异常都会执行finally后的代码
# try:
#    fh = open("testfile", "w")
#    fh.write("This is my test file for exception handling!!")
# finally:
#    print("Error: can\'t find file or read data")

# re 模块

# re.match(pattern, string, flags)
# re.match(x,y,z).group(num)   # 用小括号，  num返回匹配的第几项
# re.search(x,y,z).group()   #返回匹配项
#
# re.match只匹配字符串的开始，如果字符串开始不符合正则表达式，则匹配失败，函数返回None；
# re.search匹配整个字符串，直到找到一个匹配。
#
# re.sub用于替换字符串中的匹配项
# re.sub(pattern ,replace ,string ,max=0)

# random 模块

import random

print(random.randint(1,100))
print(random.choice(('a','b','c','d')))


# math 模块
from math import pi as math_pi

print(math_pi)



#
# import MySQLdb
# dbhost = "192.168.0.191"
# dbuser = "icms"
# dbpassword = "zdhtyfb2017"
# database = 'CodeCal'
#
#  #打开数据库连接
# db = MySQLdb.connect(dbhost , dbuser , dbpassword, database)
#  #操作游标
# cursor = db.cursor()
#  #执行sql
# cursor.execute("select version()")
#  # 获取数据
# data = cursor.fetchone()  # fetchone fetchall row
#
# print("Database version is %s ." % data)
#
# db.close()
